<?php

use Illuminate\Database\Migrations\Migration;
use Illuminate\Database\Schema\Blueprint;
use Illuminate\Support\Facades\Schema;

class CreateAdvertismentTable extends Migration
{
    /**
     * Run the migrations.
     *
     * @return void
     */
    public function up()
    {
        if (!Schema::hasTable('advertisments')) {
            Schema::create('advertisments', function (Blueprint $table) {
                $table->bigIncrements('id');
                $table->string('pic', 1024)->default('')->comment('广告图片');
                $table->string('link', 128)->default('')->comment('链接地址');
                $table->tinyInteger('type')->default(0)->comment('广告位置（1：首页，2：登录页）');
                $table->string('remark', 512)->default('')->comment('备注');
                $table->integer('school_id')->default('0')->comment('学校Id');
                $table->integer('created_at')->default('0')->comment('创建时间');
                $table->integer('updated_at')->default('0')->comment('更新时间');
            });

            \Illuminate\Support\Facades\DB::statement('ALTER TABLE `caidj_advertisments` comment "广告表"');
        }
    }

    /**
     * Reverse the migrations.
     *
     * @return void
     */
    public function down()
    {
        Schema::dropIfExists('agents');
    }
}
